import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenExcelButton, OpenTwoRouter } from '../Common/options'

export const Deflections = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <OpenExcelButton
                key="two"
                title="批量导入"
                OptionsEvent={OptionsEvent}
                data={{
                    save: true,
                    submit: true,
                    url: 'getDeflectionExcel',
                    pos: 'posDeflectionExcel',
                }}
            />,
            <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,
        ],
        columns: [
            { ...commonTableList.SearchSort, selectType: 'Deflections' },
            // {
            //     ...commonTableList.parentUuid,
            //     fieldProps: {
            //         fieldNames: { label: 'tableName', value: 'uuid' },
            //         options: parentUuid,
            //     },
            // },
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization, title: '项目名称' },
            {
                dataIndex: 'constructionCompany',
                title: '施工单位',
                valueType: 'input',
                ellipsis: true,
                width: 150,
            },
            {
                dataIndex: 'testDate',
                title: '巡检日期',
                valueType: 'Date',
                width: 160,
                hideInSearch: true,
            },
            {
                dataIndex: 'layerPosition',
                title: '层位',
                valueType: 'input',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'sectionPileNumber',
                title: '段落桩号',
                valueType: 'input',
                ellipsis: true,
                width: 150,
            },
            {
                dataIndex: 'averageValue',
                title: '平均值',
                valueType: 'input',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'standardDeviation',
                title: '标准差',
                valueType: 'input',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'assuranceRate',
                title: '保证率系数',
                valueType: 'input',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'representativeValue',
                title: '代表值',
                valueType: 'input',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'designDeflectionValue',
                title: '设计弯沉值',
                valueType: 'input',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
            },
            {
                dataIndex: 'conclusion',
                title: '结论',
                valueType: 'input',
                ellipsis: true,
                width: 150,
            },
            {
                dataIndex: 'detectionPoints',
                title: '检测点数',
                valueType: 'input',
                ellipsis: true,
                width: 150,
                hideInSearch: true,
            },
            commonTableList.BeginSecurityDate,
            commonTableList.EndSecurityDate,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <OpenTwoRouter
                            key="TwoTwo"
                            title="附件管理"
                            twoTitle="弯沉管理附件信息"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'AttachmentDetails',
                                actionRef,
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
